﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Media;
using System.Runtime.InteropServices;
using System.Text;
using Microsoft.DirectX.DirectSound;

namespace Client
{
    public class ClientGlobals
    {
        public const int ScreenWidth = 1024;
        public const int ScreenHeight = 768;


        // Debug Stuff
        public static bool DebugMode = true;

        public static List<string> SoundList; // SoundList
        public static SoundPlayer Sound;

        #region Client User Options 

        public static bool BoPlaySoundEffect = true;
        public static bool BoViewEffect = true;

        #endregion


        public static string GetValidStr(string str, ref string dest, char divider)
        {
            string[] strsplit = str.Split(divider);
            dest = strsplit[0].Trim();
            return strsplit[1].Trim();
        }

        public static bool PickString(string source, out string buffer, int index, params char[] sep)
        {
            int pos = 0, next;
            int cur_index = 0;

            buffer = string.Empty;
            while (cur_index <= index)
            {
                next = source.IndexOfAny(sep, pos);

                if (cur_index == index)
                {
                    if (next >= 0)
                    {
                        buffer = source.Substring(pos, next - pos);
                        return true;
                    }

                    buffer = source.Substring(pos);
                    return true;
                }

                if (next < 0) break;

                ++cur_index;
                pos = next + Marshal.SizeOf(typeof(Char));
            }

            return false;
        }
    }
}
